package com.lht.cozyCloud.bee.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author lht
 * @version 1.0
 * @description:
 * @date 2024/11/8 10:15
 */
@Component
public class Properties implements InitializingBean { // 实现InitializingBean，在bean初始化完之后，回调，进行一些基本操作

    // spring的依赖注入是基于实例化的对象，通过setter注入，无法通过@Value为静态属性赋值
    @Value("${aliyun.sms.regionId}")
    private String regionId;

    @Value("${aliyun.sms.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.sms.secret}")
    private String secret;

    public static String REGION_Id;
    public static String ACCESS_KEY_ID;
    public static String SECRECT;

    @Override
    public void afterPropertiesSet() throws Exception {  // bean初始化完成后，将配置赋予静态变量，后续可以直接使用静态变量
        REGION_Id=regionId;
        ACCESS_KEY_ID=accessKeyId;
        SECRECT=secret;
    }
}
